<?php
namespace Admin\Controller;
use Think\Controller;
class JoinUsController extends BaseController {
    public function index(){
    	$this->login_verify();

    	$joinus=M("joinus");
        $data=$_GET['type'];
        if(empty($data)){
            $data=1;
        }
        $joinuslist=$joinus->where("type=".$data)->select();
        // var_dump($joinuslist);
        $this->assign("type",$_GET['type']);
        $this->assign("joinuslist", $joinuslist);

        $this->display();
    } 
    public function getContent(){
        $data['type']=$_POST['type'];
        $joinus=M("joinus");
        $joinuslist=$joinus->where("type=".$data['type'])->select();
        $this->ajaxReturn($joinuslist);
    }
     public function addJoinUs(){
     	$joinus=M("joinus");
        $data['type']=$_POST['type'];
    	$data["content"]=$_POST["content"];
    	$data["time"]=date('Y-m-d H:i:s');
    	if($joinus->add($data)){
    		$this->success('添加成功', U('JoinUs/index',array('type'=>$data['type'])));
    	}else{
    		$this->error('添加失败');
    	}
    }
    public function joinusDel(){
        $id=I('get.id');
        $data['type']=$_POST['type'];
        $joinus=M('joinus');
        if($joinus->where('id='.$id)->delete()){
                $this->success("删除成功",U('JoinUs/index',array('type'=>$data['type'])));
        }else{
                $this->error("删除失败");
        }
    }
}